package com.springmvc.init.handlerAdapter;

import com.springmvc.controller.Controller;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Component
public class BeanNameHandlerAdapter implements HandlerAdapter {
    @Override
    public boolean isSuuport(Object object) {
        return object instanceof Controller;
    }
    @Override
    public Object handler(HttpServletRequest request, HttpServletResponse response, Object handler) {
        if(handler != null && handler instanceof Controller){
            Controller controller = (Controller) handler;
            return controller.handler(request,response);
        }

        return null;
    }
}
